﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace FCS.Test
{
    /// <summary>
    /// Summary description for MapsTests
    /// </summary>
    [TestClass]
    public class MapsTests : Functional
    {
        public MapsTests()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        [TestMethod]
        public void SimleMapTest()
        {
            Assert.AreEqual(5, Length(Map(x => x * 2, IntList(1, 5))));
            Assert.AreEqual(0, Length(Map(x => x * 2, IntList(1, -1))));
            Assert.AreEqual(1, Length(Map(x => x * 2, IntList(1, 1))));

            Assert.IsTrue(Equals(ListFromArray(2, 4, 6, 8, 10), Map(x => x * 2, IntList(1, 5))));
            Assert.IsTrue(Equals(Empty<int>(), Map(x => x * 2, IntList(1, -1))));
            Assert.IsTrue(Equals(ListFromArray(2), Map(x => x * 2, IntList(1, 1))));
        }

        [TestMethod]
        public void IndexedMapTest()
        {
            Assert.AreEqual(5, Length(Map((x, i) => x * 2 + i, IntList(1, 5))));
            Assert.AreEqual(0, Length(Map((x, i) => x * 2 + i, IntList(1, -1))));
            Assert.AreEqual(1, Length(Map((x, i) => x * 2 + i, IntList(1, 1))));

            Assert.IsTrue(Equals(ListFromArray(2, 5, 8, 11, 14), Map((x, i) => x * 2 + i, IntList(1, 5))));
            Assert.IsTrue(Equals(Empty<int>(), Map((x, i) => x * 2 + i, IntList(1, -1))));
            Assert.IsTrue(Equals(ListFromArray(2), Map((x, i) => x * 2 + i, IntList(1, 1))));
        }
    }
}
